/**
 * @author peter
 * This is a subclass of bk_editor which implements Christophe Dolivets EditArea source code editor
 */
dojo.provide("bunkai.bk_editor_editarea");
dojo.declare("bunkai.bk_editor_editarea", bunkai.bk_editor,
{
	/*
	 * <div id="widgetpane" dojoType="dijit.layout.TabContainer" title="Widgets">
				<div dojoType="dijit.layout.ContentPane" title="Dijits" id="widgets" class="container" executeScripts="true">
					
					<ul id="wlist">
					</ul>
					
				</div>
				<div dojoType="dijit.layout.ContentPane" title="Bunkai extras" id="extras" class="container" executeScripts="true">
					
					<ul id="elist">
					</ul>
					
				</div>
			</div>
			
			<div dojoType="dijit.Dialog" id="dialog1" title="Node operations for:" execute="handleDialog">
	<form id="nodeform" dojoType="dijit.form.Form" action="handleDialog();">
	
    	<table>
        <tr>
        <td><label for="name">New Node Name: </label></td>
                <td><input dojoType="dijit.form.TextBox" type="text" name="title" id="newnodename"></td>
        </tr>
        <tr>
                <td><label for="type">New Node Type: </label></td>
                <td><input dojoType="dijit.form.TextBox" type="text" name="sling:resourceType" id="newnodetype"></td>
        </tr>
        <tr>
                <td colspan="2" align="center">
                       	<button dojoType=dijit.form.Button onClick="handleDialog();">OK</button>
			<button dojoType=dijit.form.Button onClick="dijit.byId('dialog1').hide()">Cancel</button>
			<button dojoType=dijit.form.Button onClick="deleteNode();">Delete This Node</button>
		</td>
        </tr>
    	</table>
	</form> 
	</div>
	 */
	editAreaLoader: "bk_editor_editarea",
	
	constructor: function()
	{
		console.log("init called...");
		this.inherited("postCreate",arguments);
		//
		var eadiv = docuemnt.createElement('div');
		eadiv.id = "";
		this.fpane.domNode.appendChild(eadiv);
		//
		try
		{
			this.editAreaLoader.init({
			id: "editor"	// id of the textarea to transform	
			,start_highlight: true	
			,font_size: "8"
			,font_family: "verdana, monospace"
			,allow_resize: "y"
			,allow_toggle: false
			,language: "en"
			,syntax: "html"	
			,toolbar: "new_document, save, load, |, charmap, |, search, go_to_line, |, undo, redo, |, select_font, |, change_smooth_selection, highlight, reset_highlight, |, help"
			,load_callback: this.eaload
			,save_callback: this.easave
			,plugins: "charmap"
			,charmap_default: "arrows"				
			});	
			
		}
		catch (e)
		{
			console.log("editinit error: "+e);
		}
	},
	
	eaload: function(data)
	{
		console.log("bk_editor_editarea eaload called with "+data.length+" bytes of data");
	},
	
	easave: function(id, data)
	{
		console.log("bk_editor_editarea easave called with id="+id+", "+data.length+" bytes of data");
	},
	
	// Gets called by logic in superclass when our file has been updated
	update: function(data)
	{
		console.log("******* Setting editor contents to **********")
		console.log(data);
		this.editAreaLoader.setValue("editor", data);
	}

});